package com.yb.guigu.pick.web.config;

import com.yb.guigu.pick.web.filter.DelayFilter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/6/1 10:55
 * FileName: DelayConfig
 * Description:
 */

public class DelayConfig {

    @Value("${guigu.pick.delay.time:3000}")
    Long time;

    @Bean
    @Order(-1)
    public FilterRegistrationBean<DelayFilter> delayFilter() {
        FilterRegistrationBean<DelayFilter> filterRegistrationBean = new FilterRegistrationBean<>(new DelayFilter(time));
        filterRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return filterRegistrationBean ;
    }
}
